package com.lk.demo.repos;

import com.lk.demo.model.Book;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;

import java.util.List;


@Repository
public interface BookRepository extends JpaRepository<Book, Long> {
    Book findByIsbn(String isbn);

    List<Book> findByNameLike(String name);

    @Query(value = "select b from Book b left join b.authors a where b.name like %?1% or a.name like %?2%")
    List<Book> findBooks(String bookName, String authorName);
}
